/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.QueryConfigDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.QueryConfigDO;
import org.springframework.dao.DataAccessException;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.QueryConfigDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_query_config.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisQueryConfigDAO extends SqlMapClientDaoSupport implements QueryConfigDAO {

    /**
     *  Insert one <tt>QueryConfigDO</tt> object to DB table <tt>sgw_query_config</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_query_config(id,trans_type_id,channel_system_id,query_type,query_priority,query_time_range,query_param,receipt,execute_switch,gmt_create,gmt_modified,memo,query_task_type,query_trans_type_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate, sysdate, ?, ?, ?)</tt>
     *
     *	@param queryConfig
     *	@return int
     *	@throws DataAccessException
     */
    public int insert(QueryConfigDO queryConfig) throws DataAccessException {
        if (queryConfig == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-QUERY-CONFIG-INSERT", queryConfig);

        return queryConfig.getId();
    }

    /**
     *  Query DB table <tt>sgw_query_config</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, trans_type_id, channel_system_id, query_type, query_priority, query_time_range, query_param, receipt, execute_switch, gmt_create, gmt_modified, memo, query_task_type, query_trans_type_id from sgw_query_config where ((trans_type_id = ?) AND (channel_system_id = ?) AND (query_type = ?) AND (receipt LIKE ?) AND (query_task_type = ?))</tt>
     *
     *	@param transTypeId
     *	@param channelSystemId
     *	@param queryType
     *	@param receipt
     *	@param queryTaskType
     *	@return List<QueryConfigDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<QueryConfigDO> select(String transTypeId, String channelSystemId, String queryType,
                                      String receipt, String queryTaskType)
                                                                           throws DataAccessException {
        Map param = new HashMap();

        param.put("transTypeId", transTypeId);
        param.put("channelSystemId", channelSystemId);
        param.put("queryType", queryType);
        param.put("receipt", receipt);
        param.put("queryTaskType", queryTaskType);

        return getSqlMapClientTemplate().queryForList("MS-QUERY-CONFIG-SELECT", param);

    }

    /**
     *  Query DB table <tt>sgw_query_config</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, trans_type_id, channel_system_id, query_type, query_priority, query_time_range, query_param, receipt, execute_switch, gmt_create, gmt_modified, memo, query_task_type, query_trans_type_id from sgw_query_config where (id = ?)</tt>
     *
     *	@param id
     *	@return QueryConfigDO
     *	@throws DataAccessException
     */
    public QueryConfigDO selectById(int id) throws DataAccessException {
        Integer param = new Integer(id);

        return (QueryConfigDO) getSqlMapClientTemplate().queryForObject(
            "MS-QUERY-CONFIG-SELECT-BY-ID", param);

    }

    /**
     *  Update DB table <tt>sgw_query_config</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_query_config set trans_type_id=?, channel_system_id=?, query_type=?, query_priority=?, query_time_range=?, query_param=?, receipt=?, execute_switch=?, gmt_modified=sysdate, memo=?, query_task_type=?, query_trans_type_id=? where (id = ?)</tt>
     *
     *	@param transTypeId
     *	@param channelSystemId
     *	@param queryType
     *	@param queryPriority
     *	@param queryTimeRange
     *	@param queryParam
     *	@param receipt
     *	@param executeSwitch
     *	@param memo
     *	@param queryTaskType
     *	@param queryTransTypeId
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String transTypeId, String channelSystemId, String queryType,
                      String queryPriority, String queryTimeRange, String queryParam,
                      String receipt, String executeSwitch, String memo, String queryTaskType,
                      String queryTransTypeId, int id) throws DataAccessException {
        Map param = new HashMap();

        param.put("transTypeId", transTypeId);
        param.put("channelSystemId", channelSystemId);
        param.put("queryType", queryType);
        param.put("queryPriority", queryPriority);
        param.put("queryTimeRange", queryTimeRange);
        param.put("queryParam", queryParam);
        param.put("receipt", receipt);
        param.put("executeSwitch", executeSwitch);
        param.put("memo", memo);
        param.put("queryTaskType", queryTaskType);
        param.put("queryTransTypeId", queryTransTypeId);
        param.put("id", new Integer(id));

        return getSqlMapClientTemplate().update("MS-QUERY-CONFIG-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_query_config</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_query_config where (id = ?)</tt>
     *
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(int id) throws DataAccessException {
        Integer param = new Integer(id);

        return getSqlMapClientTemplate().delete("MS-QUERY-CONFIG-DELETE", param);
    }

}